import request from '@/utils/request'
// 获取管理员列表
export const userList = params => {
  return request({
    method: 'GET',
    url: '/users',
    params
  })
}
// 更新用户状态
export const userStateChange = (id, status) => {
  return request({
    method: 'PUT',
    url: `users/${id}/state/${status}`
  })
}
// 删除用户
export const delUser = id => {
  return request({
    method: 'DELETE',
    url: `/users/${id}`
  })
}
// 添加用户
export const addUser = data => {
  return request({
    method: 'post',
    url: '/users',
    data
  })
}
// 查询单个用户信息
export const getUserById = id => {
  return request({
    method: 'GET',
    url: '/users/' + id
  })
}
// 编辑用户信息
export const editUser = (id, data) => {
  return request({
    method: 'put',
    url: '/users/' + id,
    data
  })
}
// 给用户分配角色
export const setUserRole = (id, rid) => {
  return request({
    method: 'put',
    url: `/users/${id}/role`,
    data: {
      id,
      rid
    }
  })
}
